<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function myInstanceof(sub, parent) {
      if(typeof sub !== 'object' || typeof sub === 'null') return false
      let __proto__ = Object.getPrototypeOf(sub)
      while(__proto__) {
        if(__proto__ === parent.prototype) return true
        __proto__ = Object.getPrototypeOf(__proto__)
      }
      return false
    }

    console.log(myInstanceof(new Number(123), Number));    // true
    console.log(myInstanceof(123, Number));  
  </script>
</body>
</html>